#include <unistd.h>
#include "../apue.h"

static int globval;
static int f(void);

int main(void)
{
    char * s;
    int i;
    volatile int j;
    register int k;

    i = j = k =4;
    globval = 10;

    if (f() == 0)
        s = "parent";
    else
        s = "child";

    i++;
    j++;
    k++;
    globval++;

    printf("%s: i = %d, j = %d, k = %d, globval = %d\n", s, i, j, k, globval);
    exit(0);
}

static int f(void)
{
    pid_t pid;

    if ((pid = vfork()) < 0)
        err_sys("vfork error");
    else if (pid == 0)
        return 1;
    else
        return 0;
}
